<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div {
      width: 200px;
      border: antiquewhite 1px solid;
      padding-top: 50px;
      padding-bottom: 50px
    }

    span {
      font-size: 30px;
    }
  </style>
</head>

<body>
  <div>
    <span>给父元素设置上下padding相等就能使子元素垂直居中，缺点是父元素不能有固定高度</span>
  </div>
</body>

</html>